<template>
	<view class="view-page-box">
		<NavBar left-icon="undo-filled" @onLeftIcon="back">
			<template v-slot:center>
				<view class="nav_center">
					{{fileEntity.fileTitle || fileEntity.title}}
				</view>
			</template>
		</NavBar>
		<web-view :src="fileEntity.fileUrl"></web-view>
	</view>
</template>

<script>
	import {
		api,
		post
	} from '@/util/api.js'
	import NavBar from './NavBar.vue'
	export default {
		components: {
			NavBar
		},
		data() {
			return {
				type: 0, // 0 表示项目附件，1 表示合同附件
				fileEntity: {},
			}
		},
		onLoad(option) {
			this.type = option.type
			this.querySingle(option.id)
		},
		methods: {
			querySingle(id) {
				let url = this.type == 0 ? api.ProjectDataSingle : api.FileSingle
				post(url, {
					id: id
				}).then(res => {
					this.fileEntity = res.data
				})
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style>
	.view-page-box {
		margin-top: 45px;
	}
</style>
